<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateShopStaffRecordsLog extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_staff_records_log', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopId')->default(0)->comment('门店ID');
            $table->unsignedInteger('shopCode')->default(0)->comment('门店Code'); // 要排序
            $table->unsignedInteger('userId')->default(0)->comment('用户ID');

            $table->tinyInteger('operateType')->default(0)->comment('操作类型:0-系统,1-内部,2-后台,3-商家');
            $table->tinyInteger('actionType')->default(0)->comment('行为类型,具体见model的actionTypeMap');

            $table->string('remark', 255)->default('')->comment('备注');

            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');

            $table->index('userId', 'idx_userId');
            $table->index('shopId', 'idx_shopId');
            $table->comment   = '门店员工备案记录表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_staff_records_log');
    }
}
